﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Saturn.App
{
    public partial class FormLineConfig : Form
    {
        SaturnWebReference.SaturnWebService soap = new Saturn.App.SaturnWebReference.SaturnWebService();
        public FormLineConfig()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            cmb_line.Enabled = true;
            cmb_location.Enabled = true;
            button2.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            cmb_line.Enabled = false;
            cmb_location.Enabled = false;
            string locaid;
            if (!String.IsNullOrEmpty(cmb_line.Text))
            {
                CommonConfig.Instance().Update("productline", cmb_line.Text);
            }
            if (!String.IsNullOrEmpty(cmb_location.Text))
            {
                locaid=((System.Data.DataRowView)(cmb_location.SelectedItem)).Row.ItemArray[1].ToString();
                CommonConfig.Instance().Update("location", cmb_location.Text);
                CommonConfig.Instance().Update("locationid", locaid);
            }        
           
            MessageBox.Show("修改已完成");
        }

        private void FormLineConfig_Load(object sender, EventArgs e)
        {
            button2.Enabled = false;
            cmb_location.DataSource = soap.GetFeedingPosition().Tables[0];
            cmb_location.ValueMember = "Excipientcode";
            cmb_location.DisplayMember = "ExcipientName";
            
            cmb_line.DataSource = soap.GetProductLine().Tables[0];
            //cmb_line.ValueMember = "id";
            cmb_line.DisplayMember = "name";
        }
    }
}